Skip to content

feat: add SchedulingToMinimizeWeightedCompletionTime model + ILP rule#809

Merged
isPANN merged 7 commits intomainfrom
505-scheduling-min-weighted-completion
Mar 29, 2026
Merged

feat: add SchedulingToMinimizeWeightedCompletionTime model + ILP rule#809
isPANN merged 7 commits intomainfrom
505-scheduling-min-weighted-completion

Conversation

@isPANN
Copy link
Copy Markdown
Collaborator

@isPANN isPANN commented Mar 28, 2026

Summary

  • Add SchedulingToMinimizeWeightedCompletionTime optimization model (misc category) -- multiprocessor scheduling that minimizes total weighted completion time using Smith's rule for per-processor ordering
  • Add direct SchedulingToMinimizeWeightedCompletionTime -> ILP reduction rule with binary assignment variables, completion-time variables, and big-M disjunctive ordering constraints
  • Register in CLI (pred create), schema, example-db, and paper (problem-def + reduction-rule)
  • 16 model tests + 6 ILP tests, all passing with --features ilp-highs

Closes #505
Companion rule for #783

Test plan

  • cargo clippy --all-targets --features ilp-highs -- -D warnings passes
  • cargo test --features "ilp-highs example-db" --workspace -- all tests pass (22 new tests)
  • cargo fmt --check passes
  • typst compile -- paper builds without errors
  • CI green on all platforms

🤖 Generated with Claude Code

…le (#505)

Implement the multiprocessor scheduling optimization problem (SS13 from
Garey & Johnson) that minimizes total weighted completion time with
Smith's rule ordering on each processor, plus its direct ILP reduction.

- Model: Min<u64> value type, dims=[m; n], Smith's rule for per-processor ordering
- ILP rule: binary assignment + completion time + ordering variables with big-M constraints
- 16 model tests + 6 ILP tests, all passing
- CLI: pred create support, schema registration
- Paper: problem-def + reduction-rule entries with bibliography

Closes #505

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.88%. Comparing base (a4b8656) to head (e0cdb73).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #809      +/-   ##
==========================================
+ Coverage   97.87%   97.88%   +0.01%     
==========================================
  Files         639      643       +4     
  Lines       70008    70418     +410     
==========================================
+ Hits        68517    68926     +409     
- Misses       1491     1492       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GiggleLiu
Copy link
Copy Markdown
Contributor

Agentic Review Report

Structural Check

Structural Review: model+rule SchedulingToMinimizeWeightedCompletionTime

Structural Completeness

# Check Status
1 Model file exists PASS — src/models/misc/scheduling_to_minimize_weighted_completion_time.rs
2 inventory::submit! present PASS — src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:14
3 Serde support on model PASS — derives Serialize and provides validated custom Deserialize/TryFrom at src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:60 and src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:180
4 Problem trait impl PASS — src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:207
5 Aggregate value present PASS — type Value = Min<u64> at src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:209
6 #[cfg(test)] + #[path = ...] link PASS — src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:243
7 Model test file exists PASS — src/unit_tests/models/misc/scheduling_to_minimize_weighted_completion_time.rs
8 Model test file has >= 3 tests PASS — 16 tests in src/unit_tests/models/misc/scheduling_to_minimize_weighted_completion_time.rs
9 Registered in misc/mod.rs PASS — src/models/misc/mod.rs:86 and src/models/misc/mod.rs:127
10 Re-exported in models/mod.rs PASS — src/models/mod.rs:44
11 Variant registration exists PASS — crate::declare_variants! at src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:224
12 CLI name resolution PASS — canonical names are registry-resolved in problemreductions-cli/src/problem_name.rs:23
13 CLI create support PASS — problemreductions-cli/src/commands/create.rs:3063
14 Canonical model example registered PASS — src/models/misc/mod.rs:160
15 Paper display-name entry PASS — docs/paper/reductions.typ:181
16 Paper problem-def block PASS — docs/paper/reductions.typ:5594
17 Rule file exists PASS — src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs
18 #[reduction(...)] macro present PASS — src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:65
19 ReductionResult impl present PASS — src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:45
20 ReduceTo impl present PASS — src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:71
21 #[cfg(test)] + #[path = ...] link PASS — src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:198
22 Rule test file exists PASS — src/unit_tests/rules/schedulingtominimizeweightedcompletiontime_ilp.rs
23 Closed-loop rule test present PASS — src/unit_tests/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:83
24 Registered in rules/mod.rs PASS — src/rules/mod.rs:206
25 Canonical rule example registered PASS — src/rules/mod.rs:373
26 Example-db lookup tests exist PASS — project-wide example-db coverage exists in src/unit_tests/example_db.rs
27 Paper reduction-rule entry PASS — docs/paper/reductions.typ:5664
28 Blacklisted generated files absent PASS — no forbidden generated artifacts were committed in this diff

Build Status

  • make test: PASS
  • make clippy: PASS

Semantic Review

  • Model evaluate(): OK — compute_weighted_completion_time() groups tasks by processor and applies Smith's rule via exact cross-product comparison, then accumulates the weighted completion objective with overflow checks (src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:145).
  • Model dims(): OK — vec![self.num_processors; self.num_tasks()] matches the issue's assignment-only configuration space (src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:215).
  • Size getters / overhead names: OK — num_tasks() and num_processors() exist and match the complexity / overhead symbols used by the model and rule (src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:111, src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:117).
  • Weight handling: OK — the model keeps weights as inherent fields/getters rather than introducing extra traits (src/models/misc/scheduling_to_minimize_weighted_completion_time.rs:126).
  • extract_solution(): OK for valid ILP outputs — it decodes the one-hot assignment block back to per-task processor indices (src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:54).
  • Overhead accuracy: ISSUE — the implemented ILP omits the C_t <= M bounds required by issue #783 step 6. The code adds only C_t >= l_t at src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:107, and the emitted canonical bundle has 25 variables / 70 constraints rather than the 75 documented in the issue packet. The current overhead formula at src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:68 matches the implementation, but not the issue specification.
  • Paper quality: ISSUE — the main model definition introduces the assignment map p : T -> {1, ..., m} and then immediately defines C(t) = sigma(t) + ell(t) without defining sigma, so the mathematical statement is internally inconsistent as written (docs/paper/reductions.typ:5595).

Issue Compliance

# Check Status
1 Model name matches issue #505 OK
2 Model mathematical definition matches OK — assignment-only configuration with Smith-order evaluation matches #505
3 Model framing matches OK — implemented as optimization with Value = Min<u64>
4 Model type parameters match OK — no variants/type parameters
5 Model configuration space matches OK — dims() = [m; n]
6 Model feasibility / evaluation matches OK — invalid configs return Min(None); valid assignments induce processor-wise Smith schedules
7 Model objective matches OK — computes Σ w(t) * C(t)
8 Model complexity matches OK — num_processors^num_tasks
9 Rule source/target match issue #783 OK
10 Rule reduction algorithm matches issue ISSUE — missing the C_t <= M bounds from issue #783 step 6, so the implemented ILP is slightly weaker than the specified formulation
11 Rule solution extraction matches issue OK
12 Rule correctness is preserved in current worktree OK — closed-loop and CLI solve/reduce runs recover the expected optimum 47
13 Rule overhead expressions match issue ISSUE — issue #783 documents 3 * num_tasks + ... constraints (75 on the canonical example), while the implementation emits 2 * num_tasks + ... (70 on the canonical example)
14 Rule example matches expected outcome OK — current tests and CLI run reproduce the issue/example optimum 47

Summary

  • 28/28 structural checklist items passed.
  • make test clippy passed in the review worktree.
  • ISSUE: src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:107 omits the C_t <= M bounds promised by issue #783, which changes the documented constraint count from 75 to 70 on the canonical example.
  • ISSUE: docs/paper/reductions.typ:5595 uses sigma(t) without defining it after introducing p as the assignment map.

Quality Check

Quality Review

Design Principles

  • DRY: OK — the model/rule follow existing scheduling and ILP patterns without obvious copy-paste debt beyond project-standard create/help boilerplate.
  • KISS: OK — the model stays assignment-only, and the rule uses a straightforward x/C/y layout without unnecessary abstraction.
  • HC/LC: OK — model logic, rule logic, tests, CLI registration, and paper/docs remain separated cleanly by module.

HCI (CLI changed)

  • Error messages: OK — e.g. missing --weights reports an actionable usage string for the new create path.
  • Discoverability: ISSUE — pred reduce --help still advertises pred reduce problem.json --to ILP -o reduced.json (problemreductions-cli/src/cli.rs:790), but this feature only works when the target is spelled ILP/i32.
  • Consistency: ISSUE — pred solve /tmp/scheduling_wct.json auto-reduces successfully to ILP, while the explicit pred reduce ... --to ILP and pred path ... ILP flows fail for the same problem unless the user adds /i32.
  • Least surprise: ISSUE — the fallback hint in problemreductions-cli/src/commands/reduce.rs:129 repeats the non-working plain-ILP recipe (pred path <SRC> ILP -o path.json), so a user who follows the hint hits another failure immediately.
  • Feedback: OK — successful create/solve/reduce commands report outputs clearly and the explicit ILP/i32 flow works end to end.

Test Quality

  • Naive test detection: ISSUE
    • src/unit_tests/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:9 checks num_vars and objective coefficients, but nothing asserts the documented completion upper bounds or the expected 75-constraint canonical example. That gap is why the C_t <= M drift is currently unguarded.

Issues

Critical (Must Fix)

  • None.

Important (Should Fix)

  • src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:107 / src/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:68: the ILP rule omits the C_t <= M bounds from issue #783, so the implemented reduction no longer matches the documented size formula/example count.
  • problemreductions-cli/src/cli.rs:790 / problemreductions-cli/src/commands/reduce.rs:129: the explicit reduce/path UX tells users to target plain ILP, but the new rule is only reachable through ILP/i32; the generated hint currently loops the user into another failing command.
  • src/unit_tests/rules/schedulingtominimizeweightedcompletiontime_ilp.rs:9: the rule tests do not pin the missing-bound / constraint-count behavior, so the spec drift above is not caught automatically.

Minor (Nice to Have)

  • docs/paper/reductions.typ:5595: rename or define the scheduling/start-time function consistently instead of mixing p and sigma in the same sentence.

Summary

  • The implementation is structurally clean and all build/test gates passed.
  • The main correctness/spec issue is the missing C_t <= M family in the ILP reduction relative to issue #783.
  • The main UX issue is that explicit reduce/path guidance for ILP targets is still variant-insensitive, even though this feature needs ILP/i32.

Agentic Feature Tests

Feature Test Report: problemreductions

Date: 2026-03-29
Project type: CLI + library
Features tested: SchedulingToMinimizeWeightedCompletionTime model discovery/create/solve and explicit -> ILP/i32 reduction
Profile: ephemeral
Use Case: downstream CLI user wants to discover the new scheduling model from the catalog, create the canonical example, solve it, then explicitly reduce it to ILP and solve the reduction bundle.
Expected Outcome: the model should be discoverable from CLI docs/listing, the example should build, direct solve should return the expected optimum 47, and the explicit ILP reduction path should be runnable from docs/help without guesswork.
Verdict: fail
Critical Issues: 0

Summary

Feature Discoverable Setup Works Expected Outcome Met Doc Quality
SchedulingToMinimizeWeightedCompletionTime model + ILP rule partial yes yes partial generic ILP target guidance is misleading

Per-Feature Details

SchedulingToMinimizeWeightedCompletionTime model + ILP rule

  • Role: downstream CLI user reading built-in help and catalog output.
  • Use Case: inspect the new model, create the canonical example, solve it directly, then reduce it to ILP and solve the bundle.
  • What they tried:
    • ./target/debug/pred list
    • ./target/debug/pred show SchedulingToMinimizeWeightedCompletionTime
    • ./target/debug/pred create --example SchedulingToMinimizeWeightedCompletionTime -o /tmp/scheduling_wct.json
    • ./target/debug/pred solve /tmp/scheduling_wct.json
    • ./target/debug/pred reduce /tmp/scheduling_wct.json --to ILP
    • ./target/debug/pred path SchedulingToMinimizeWeightedCompletionTime ILP
    • ./target/debug/pred path SchedulingToMinimizeWeightedCompletionTime ILP/i32
    • ./target/debug/pred reduce /tmp/scheduling_wct.json --to ILP/i32 -o /tmp/scheduling_wct_ilp.json
    • ./target/debug/pred solve /tmp/scheduling_wct_ilp.json --solver ilp
  • Discoverability: Partial — the model appears correctly in pred list, pred show is informative, and the outgoing reduction is visible; the friction starts when the user tries to run the explicit ILP reduction from generic help text.
  • Setup: Yes — the built workspace binary was sufficient; no external setup beyond the repo build was needed.
  • Functionality: Yes — direct solve returned Min(47) with solution [0,1,0,1,0], and the explicit ILP/i32 reduction bundle also solved back to the same optimum.
  • Expected vs Actual Outcome: Partial — the feature works end to end, but only after the user guesses ILP/i32; the advertised plain ILP spelling fails for explicit reduce/path flows.
  • Blocked steps: None.
  • Friction points:
    • pred reduce /tmp/scheduling_wct.json --to ILP fails with No witness-capable reduction path ... even though the direct rule exists.
    • The failure hint recommends pred path SchedulingToMinimizeWeightedCompletionTime ILP -o path.json, which also fails; the working target spelling is ILP/i32.
  • Doc suggestions: preserve target variants in explicit reduce/path help and error hints, or suggest pred show ILP/i32 / pred path <SRC> ILP/i32 when the target has no variant-free witness path.

Expected vs Actual Outcome

  • Expected: a user could follow catalog/help output to explicitly reduce the new scheduling model to ILP.
  • Actual: the model is discoverable and fully functional, but the explicit reduction path is only discoverable if the user already knows to use ILP/i32 instead of the plain ILP spelling shown in help/error text.

Issues Found

  • Important (confirmed): explicit pred reduce/path ... ILP guidance is misleading in the current worktree; the working target is ILP/i32.
  • Minor (confirmed): inspecting the generated canonical reduction bundle shows 25 variables / 70 constraints, not the 75-constraint example stated in issue #783 and the review packet.

Suggestions

  • Update explicit reduce/path help and hints to preserve target variants.
  • Add a rule-level assertion for the canonical constraint count / completion upper bounds so the ILP formulation matches its issue specification.

Generated by review-pipeline

isPANN and others added 2 commits March 29, 2026 22:11
…e conflicts)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… time description

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds completion-time upper bound constraints (C_t <= M where M = Σ l(t))
to tighten the LP relaxation. Updates overhead formula from 2*n to 3*n
bound constraints, matching the 75-constraint canonical example.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@zazabap zazabap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

isPANN and others added 2 commits March 30, 2026 01:42
Resolve import conflicts: keep both SchedulingToMinimizeWeightedCompletionTime
and KthLargestMTuple in create.rs and mod.rs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@isPANN isPANN merged commit f3837e2 into main Mar 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Model] SchedulingToMinimizeWeightedCompletionTime

3 participants